#include <iostream>
#include <vector>

using namespace std;

vector<int> dp;
vector<int> Distance;

int Least_Jump(int n)
{
    dp[0] = 1;
    for (int i = 0; i < n; i++)
        for (int j = 1; j <= Distance[i]; j++)
            dp[i + j] = min(dp[i] + 1, dp[i + j]);

    return dp[n - 1];
}

int main()
{
    int n;

    while (true)
    {
        dp.clear();
        Distance.clear();

        cout << "请输入木桩数量n=";
        cin >> n;
        dp.resize(n, 0x7FFFFFFF);
        Distance.resize(n, 0);

        cout << "请输入" << n << "个木桩上的弹簧力量" << endl;
        for (int i = 0; i < n; i++)
            cin >> Distance[i];

        cout << "最少条数为：" << Least_Jump(n) << endl;
    }
}